//
//  XLScheduleCell.m
//  industry
//
//  Created by xl on 2020/12/21.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLScheduleCell.h"
#import "XLApproveModel.h"

@interface XLScheduleCell ()

@property (nonatomic, strong) XLView *bgView;
@property (nonatomic, strong) XLLabel *nameLB;
@property (nonatomic, strong) XLLabel *titleLB;
@property (nonatomic, strong) XLImageView *iconIG;
@property (nonatomic, strong) XLLabel *infoLB;
@property (nonatomic, strong) XLLabel *timeLB;
@property (nonatomic, strong) XLView *tag1View;
@property (nonatomic, strong) XLView *tag2View;

@end
@implementation XLScheduleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteBgColor];
        [self.contentView addSubview:self.bgView];
        [self.bgView addSubview:self.nameLB];
        [self.bgView addSubview:self.titleLB];
        [self.bgView addSubview:self.iconIG];
        [self.bgView addSubview:self.tag1View];
        [self.bgView addSubview:self.tag2View];
        [self.bgView addSubview:self.infoLB];
        [self.bgView addSubview:self.timeLB];
        
        [self makeConstraint];
    }
    return self;
}

- (void)makeConstraint {
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [_nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.bgView).offset(20);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLB.mas_right).offset(15);
        make.centerY.equalTo(self.nameLB);
    }];
    
    [_iconIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView).offset(-30);
        make.top.equalTo(self.bgView);
        make.size.mas_equalTo(CGSizeMake(37, 36));
    }];
    
    [_tag1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).offset(28);
        make.top.equalTo(self.nameLB.mas_bottom).offset(17);
        make.size.mas_equalTo(CGSizeMake(4, 4));
    }];
    
    [_infoLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.tag1View);
        make.left.equalTo(self.tag1View.mas_right).offset(11);
    }];
    
    [_tag2View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).offset(28);
        make.top.equalTo(self.tag1View.mas_bottom).offset(22);
        make.size.mas_equalTo(CGSizeMake(4, 4));
    }];
    
    [_timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.tag2View);
        make.left.equalTo(self.tag2View.mas_right).offset(11);
    }];
}


#pragma mark - Public
- (void)loadCellData:(id)cellData {
    XLApproveModel * model = (XLApproveModel *) cellData;
    _nameLB.text = model.approveTypeName;
    _titleLB.text = model.contractNo;
    _iconIG.image = XLIMAGE(@"fn");//systemName
    _infoLB.text = model.cusName;
    _timeLB.text = model.processTime;

}

#pragma mark - setter/getter
- (XLView *)bgView {
    if (!_bgView) {
        _bgView = [XLView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 20.0f;
        _bgView.layer.shadowColor = [UIColor colorWithHex:0x000000 alpha:0.08].CGColor;
        _bgView.layer.shadowOffset = CGSizeMake(0,6);
        _bgView.layer.shadowOpacity = 1;
        _bgView.layer.shadowRadius = 20;
    }
    return _bgView;
}

- (XLLabel *)nameLB {
    if (!_nameLB) {
        _nameLB = [XLLabel new];
        _nameLB.font = [UIFont fontOfPingFangSCRegularWithSize:13];
        _nameLB.textColor = [UIColor whiteColor];
        _nameLB.backgroundColor = [UIColor blueBgColor];
        _nameLB.textAlignment = NSTextAlignmentCenter;
        _nameLB.layer.cornerRadius = 20.0f;
        _nameLB.layer.masksToBounds = YES;
    }
    return _nameLB;
}

- (XLLabel *)titleLB {
    if (!_titleLB) {
        _titleLB = [XLLabel new];
        _titleLB.font = [UIFont fontOfPingFangSCSemiboldWithSize:16];
        _titleLB.textColor = [UIColor blackFontColor];
    }
    return _titleLB;
}

- (XLImageView *)iconIG {
    if (!_iconIG) {
        _iconIG = [XLImageView new];
    }
    return _iconIG;
}

- (XLLabel *)infoLB {
    if (!_infoLB) {
        _infoLB = [XLLabel new];
        _infoLB.font = [UIFont fontOfPingFangSCRegularWithSize:12];
        _infoLB.textColor = [UIColor grayFontColor];
    }
    return _infoLB;
}

- (XLLabel *)timeLB {
    if (!_timeLB) {
        _timeLB = [XLLabel new];
        _timeLB.font = [UIFont fontOfPingFangSCRegularWithSize:12];
        _timeLB.textColor = [UIColor grayFontColor];
    }
    return _timeLB;
}

- (XLView *)tag1View {
    if (!_tag1View) {
        _tag1View = [XLView new];
        _tag1View.backgroundColor = [UIColor blueBgColor];
        _tag1View.layer.cornerRadius = 2;
        _tag1View.layer.masksToBounds = YES;
    }
    return _tag1View;
}

- (XLView *)tag2View {
    if (!_tag2View) {
        _tag2View = [XLView new];
        _tag2View.backgroundColor = [UIColor blueBgColor];
        _tag2View.layer.cornerRadius = 2;
        _tag2View.layer.masksToBounds = YES;
    }
    return _tag2View;
}


@end
